﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Sector7.Restaurant.Modules.BIZZ.LocalService;
using System.ComponentModel;
using Sector7.Restaurant.Modules.BIZZ.Utility;
using Sector7.Framework.Utility;

namespace Sector7.Restaurant.Modules.BIZZ.Controls
{
    /// <summary>
    /// SalesDetailControl.xaml 的交互逻辑
    /// </summary>
    public partial class SalesDetailControl : UserControl
    {
        private RS_SalesBill _salesBill = null;

        public SalesDetailControl()
        {
            InitializeComponent();
        }

        private void LoadData()
        {
            grdMain.DataContext = _salesBill;
            txbTable.DataContext = _salesBill.Table;
            ClientUtil.LoadItemsSource(dtgSalesBill, _salesBill.Items);
        }

        public RS_SalesBill SalesBill
        {
            get { return _salesBill; }
            set
            {
                _salesBill = value;

                _salesBill.PropertyChanged += new PropertyChangedEventHandler(SalesBill_PropertyChanged);

                LoadData();
            }
        }

        private void SalesBill_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            LoadData();
        }
    }
}
